package org.jeecg.enums.common;

/**
 * 数据范围 - 内置
 */
public enum DataScopeEnum {
    DATA_SCOPE_ADMIN(1, "超级管理员"),
    DATA_SCOPE_TENANT_ADMIN(5, "系统管理员"),
    DATA_SCOPE_NORMAL(10, "普通角色"),
    DATA_SCOPE_SINGLE(9, "仅个人"),
    ;

    private Integer code;
    private String desc;

    DataScopeEnum(Integer code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    public Integer getCode() {
        return code;
    }

    public String getDesc() {
        return desc;
    }


    public static String getDesc(Integer value) {
        if (value == null) return  "";
        DataScopeEnum[] enums = values();
        for (DataScopeEnum typeEnum : enums) {
            if (value.intValue()  == typeEnum.getCode().intValue()) {
                return typeEnum.desc;
            }
        }
        return "";
    }

    public static Integer getValue(String desc) {
        DataScopeEnum[] enums = values();
        for (DataScopeEnum typeEnum : enums) {
            if (typeEnum.getDesc().equals(desc)) {
                return typeEnum.code;
            }
        }
        return null;
    }
}
